/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.domain;

import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
import javax.validation.constraints.*;
import java.sql.Timestamp;
import java.io.Serializable;

/**
* @website https://el-admin.vip
* @description /
* @author ...
* @date 2020-11-08
**/
@Entity
@Data
@Table(name="shuyi_reader")
public class Reader implements Serializable {

    private static final long serialVersionUID = 3450598580474759089L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "reader_id")
    @ApiModelProperty(value = "读者编号，自增长 ")
    private Integer readerId;

    @Column(name = "reader_name",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "用户姓名 ")
    private String readerName;

    @Column(name = "nickname",unique = true,nullable = false)
    @NotBlank
    @ApiModelProperty(value = "昵称 唯一 ")
    private String nickname;

    @Column(name = "password",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "密码 md5加密 ")
    private String password;

    @Column(name = "avatar")
    @ApiModelProperty(value = "头像地址 ")
    private String avatar;

    @Column(name = "identity_card",unique = true,nullable = false)
    @NotBlank
    @ApiModelProperty(value = "身份证号 唯一 ")
    private String identityCard;

    @Column(name = "phone_num",unique = true,nullable = false)
    @NotBlank
    @ApiModelProperty(value = "电话号码 唯一 ")
    private String phoneNum;

    @Column(name = "email",unique = true,nullable = false)
    @NotBlank
    @ApiModelProperty(value = "邮箱 ")
    private String email;

    @Column(name = "occupation")
    @ApiModelProperty(value = "职业 ")
    private String occupation;

    @Column(name = "professional")
    @ApiModelProperty(value = "职称 ")
    private String professional;

    @Column(name = "education")
    @ApiModelProperty(value = "学历 ")
    private String education;

    @Column(name = "level")
    @ApiModelProperty(value = "读者等级 对应r_rank表 ")
    private String level;

    @Column(name = "signature")
    @ApiModelProperty(value = "签名 ")
    private String signature;

    @Column(name = "qq_id",unique = true)
    @ApiModelProperty(value = "qqId")
    private String qqId;

    @Column(name = "wx_id",unique = true)
    @ApiModelProperty(value = "wxId")
    private String wxId;

    @Column(name = "open_id",unique = true)
    @ApiModelProperty(value = "openId")
    private String openId;

    @Column(name = "is_baned")
    @ApiModelProperty(value = "是否被封号,1被封号,0解封 ")
    private Boolean isBaned;

    @Column(name = "shipperCode")
    @ApiModelProperty(value = "物流偏好 快递公司编码 ")
    private String shippercode;

    @Column(name = "birthday",nullable = false)
    @NotNull
    @ApiModelProperty(value = "生日")
    private Timestamp birthday;

    @Column(name = "sex")
    @ApiModelProperty(value = "0:男 1:女 默认0 ")
    private Boolean sex;

    @Column(name = "phone_is_hid")
    @ApiModelProperty(value = "是否隐藏手机号码,1被隐藏,0不隐藏 ")
    private Boolean phoneIsHid;

    @Column(name = "is_enable",nullable = false)
    @NotNull
    @ApiModelProperty(value = "是否启用 1启用 0未启用")
    private Boolean isEnable;

    public void copy(Reader source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}